package cn.xz.xy.util

import android.R
import android.graphics.drawable.Drawable
import android.graphics.drawable.StateListDrawable


/**
 * 动态创建selector
 * */
object SelectorUtils {

    /**
     * 创建一个图片选择器
     * @param normalState  普通状态的图片
     * @param pressedState 按压状态的图片
     */
    fun create(normalState: Drawable?, pressedState: Drawable?): StateListDrawable? {
        val bg = StateListDrawable()
        bg.addState(intArrayOf(R.attr.state_pressed, R.attr.state_enabled), pressedState)
        bg.addState(intArrayOf(R.attr.state_enabled), normalState)
        bg.addState(intArrayOf(), normalState)
        return bg
    }

}